﻿using PDFDesign.Model;
using System;
using System.Collections.Generic;

namespace PDFDesign.ViewModel
{
    public class ReportStyleViewModel : BaseViewModel
    {
        public ReportStyleViewModel() { }

        private int num;
        /// <summary>
        /// 序号
        /// </summary>
        public int Num
        {
            get => num;
            set
            {
                num = value;
                OnPropertyChanged("Num");
            }
        }
        private ReportStyles reportStyle;
        /// <summary>
        /// 样式
        /// </summary>
        public ReportStyles ReportStyle
        {
            get => reportStyle;
            set
            {
                reportStyle = value;
                OnPropertyChanged("ReportStyle");
            }
        }

        private PDFStyle pdfStyle;
        /// <summary>
        /// PDF样式
        /// </summary>
        public PDFStyle PDFStyle
        {
            get => pdfStyle;
            set
            {
                pdfStyle = value;
                OnPropertyChanged("PDFStyle");
            }
        }


        public ReportStyleViewModel(string templateName, string styleName, PageSetting pageSetting, TableControl tableControl)
        {
            PDFStyle = new PDFStyle
            {
                PageSetting = pageSetting,
                Controls = new Controls
                {
                    Tables = new List<TableControl> { tableControl },
                    Texts = new List<TextControl>()
                }
            };
            var guid = Guid.NewGuid().ToString();
            var date = DateTime.Now;
            ReportStyle = new ReportStyles
            {
                TemplateName = templateName,
                StyleName = styleName,
                Content = Newtonsoft.Json.JsonConvert.SerializeObject(PDFStyle),
                ConfigId = 0,
                CustomerId = 7961828763877337388,
                FileKey = guid,
                Stylefomattype = 1,
                StyleNumber = date.ToString("yyyyMMddHHmmss"),
                Styletype = 1,
                Id = guid.Replace("-", ""),
                ProductType = 0,
                UpdateTime = date,
                Uploaded = 1,
                Visitor = ""
            };
        }
    }
}